package com.hospital.wx.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.hospital.wx.common.CommonResult;
import com.hospital.wx.controller.form.SelectMedicalDeptSubListForm;
import com.hospital.wx.service.MedicalDeptSubService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;

@RestController
@RequestMapping("/medical/dept/sub")
@Tag(name = "MedicalDeptSubController", description = "诊室管理接口")
@Slf4j
public class MedicalDeptSubController {

    @Autowired
    private MedicalDeptSubService medicalDeptSubService;

    @PostMapping("/selectMedicalDeptSubList")
//    @SaCheckLogin
    @Operation(summary = "根据科室ID查询诊室信息")
    public CommonResult selectMedicalDeptSubList(@RequestBody @Valid SelectMedicalDeptSubListForm form) {
        try {
            ArrayList<HashMap> list = medicalDeptSubService.selectMedicalDeptSubList(form.getDeptId());
            return CommonResult.ok().put(CommonResult.RETURN_RESULT, list);
        } catch (Exception e) {
            log.error("查询诊室列表过程中出现异常", e);
            return CommonResult.failed("查询诊室列表过程中出现异常");
        }
    }


}
